<template>
  <div class="InspectionRecord">
    <NavBar fixed placeholder title="巡检记录" z-index="999" ref="nav">
      <template #left>
        <Icon
          name="arrow-left"
          size="0.53rem"
          color="#000"
          @click="
            $router.push({
              path: 'InspectionList',
              query: {
                activeName: 'c',
              },
            })
          "
        />
      </template>
    </NavBar>
    <div class="header-img">
      <img class="bg-img" src="../../../assets/img/card.png" alt="" />
      <div class="state">任务状态 - 已巡检</div>
      <div class="id">任务编号：{{ info.ectId }}</div>
    </div>

    <Cell title="路线名称" :value="info.ecrName"></Cell>
    <Cell title="路线编号" :value="info.ecrId"></Cell>
    <Cell title="任务计划开始时间" :value="info.startTime"></Cell>
    <Cell title="任务计划结束时间" :value="info.endTime"></Cell>
    <Cell title="认领人" :value="info.checkUser"></Cell>
    <Cell title="认领时间" :value="info.claimDtm"></Cell>
    <Cell title="实际巡检人" :value="info.executor"></Cell>
    <Cell title="巡检时间" :value="info.executorTime"></Cell>

    <div class="item0" v-for="(item0, i) in list" :key="i">
      <div class="placeholder"></div>
      <div class="item-header">
        <div class="item-title" style="font-size: 20px">{{ item0.text }}</div>
        <div class="item-flag" @click="item0.flag = !item0.flag">
          <Icon :name="item0.flag ? 'arrow-up' : 'arrow-down'" />
          <span style="font-size: 20px">
            {{ item0.flag ? "展开" : "收缩" }}
          </span>
        </div>
      </div>

      <div
        v-show="item0.flag"
        class="item"
        v-for="(item, i1) in item0.list"
        :key="i1"
      >
        <div class="placeholder"></div>
        <div class="item-header">
          <div class="item-title">{{ item.text }}</div>
          <div class="item-flag" @click="item.flag = !item.flag">
            <Icon :name="item.flag ? 'arrow-up' : 'arrow-down'" />
            <span>
              {{ item.flag ? "展开" : "收缩" }}
            </span>
          </div>
        </div>
        <div class="main" v-show="item.flag">
          <div class="header">内容和方法</div>
          <div class="content">有无工作</div>
          <div class="header">判断标准</div>
          <div class="content">工作灯是否亮起</div>
          <div class="header">检查结果</div>
          <div class="btns">
            <Button class="btn" :class="{ state: item.state == 0 }"
              >正常</Button
            >
            <Button class="btn" :class="{ state: item.state == 1 }"
              >异常</Button
            >
          </div>
          <div class="header">检查意见</div>
          <textarea readonly v-model="item.content"></textarea>
          <div class="header">照片</div>
          <VanImage
            v-for="img in item.pic"
            :key="img"
            :src="/nhw/ + img"
            width="150"
            height="150"
            class="images"
            style="margin-left: 10px"
          >
          </VanImage>
        </div>
      </div>
    </div>

    <!-- <div class="item" v-for="(item, i) in list" :key="i">
      <div class="placeholder"></div>
      <div class="item-header">
        <div class="item-title">{{ item.title }}</div>
        <div class="item-flag" @click="item.flag = !item.flag">
          <Icon :name="item.flag ? 'arrow-up' : 'arrow-down'" />
          收缩
        </div>
      </div>
      <div class="main" v-show="item.flag">
        <div class="header">内容和方法</div>
        <div class="content">有无工作</div>
        <div class="header">判断标准</div>
        <div class="content">工作灯是否亮起</div>
        <div class="header">检查结果</div>
        <div class="btns">
          <Button
            class="btn"
            :class="{ state: item.state }"
            @click="item.state = true"
            >正常</Button
          >
          <Button
            class="btn"
            :class="{ state: !item.state }"
            @click="item.state = false"
            >异常</Button
          >
        </div>
        <div class="header">检查意见</div>
        <textarea readonly></textarea>
        <div class="header">照片</div>
        <img class="img" src="" alt="" />
      </div>
    </div> -->
  </div>
</template>

<script>
import { InspectionDetails } from "@/api/work";
import {
  Image as VanImage,
  Uploader,
  Popup,
  NavBar,
  Icon,
  Field,
  Cell,
  List,
  Button,
} from "vant";
export default {
  props: {},
  data() {
    return {
      info: {},
      list: [
        { title: "1111", flag: false, state: true, fileList: [] },
        { title: "222", flag: false, state: true, fileList: [] },
      ],
    };
  },
  computed: {},
  created() {
    // console.log(this.$route.query);
    this.info = this.$route.query;
    this.getInfo();
  },
  mounted() {},
  watch: {},
  methods: {
    async getInfo() {
      const { param } = await InspectionDetails({
        ectNo: this.$route.query.ectNo,
        ecrNo: this.$route.query.ecrNo,
        orgNo: localStorage.getItem("orgNo"),
      });
      console.log(param.data);
      param.data.forEach((v) => {
        v.flag = false;
        v.list.forEach((e) => {
          e.flag = false;
        });
      });
      this.list = param.data;
    },
    toJump(item) {
      if (item.state == "已检") return;
      this.$router.push("InspectionRecord");
    },
  },
  components: {
    VanImage,
    Uploader,
    Button,
    Popup,
    NavBar,
    Icon,
    Field,
    Cell,
    List,
  },
};
</script>

<style scoped lang="less">
@import "~@/style/var.less";
* {
  box-sizing: border-box;
}
.InspectionRecord {
  .flex {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .placeholder {
    width: 100%;
    height: 20px;
    background-color: #f7f7f9;
  }
  .item,
  .item0 {
    z-index: 99;
    font-size: 30px;
    .item-header {
      padding: 0 20px;
      height: 70px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .item-flag {
        color: @primary;
      }
    }
    .main {
      .header {
        height: 60px;
        padding-left: 20px;
      }
      .content {
        height: 60px;
        padding-left: 40px;
      }
      .btns {
        margin: 10px 0 30px;
        .btn {
          width: 132px;
          height: 44px;
          border-radius: 22px;
          margin-left: 30px;
          color: @primary;
          background-color: #fff;
          border: 1px solid @primary;
        }
        .state {
          background: #f8e0ce;
          border: 1px solid @primary;
        }
      }
      textarea {
        width: 95%;
        height: 180px;
        border: 1px solid #dddddd;
        border-radius: 12px;
        margin: 10px 20px 30px;
      }
      .img {
        width: 150px;
        height: 150px;
        margin-left: 20px;
        margin-bottom: 20px;
      }
    }
  }
  .header-img {
    overflow: hidden;
    width: 100%;
    height: 190px;
    // background-color: red;
    display: flex;
    flex-flow: column;
    justify-content: center;
    padding-left: 20px;
    color: #edf0f5;
    position: relative;
    .state {
      font-size: 48px;
      z-index: 99;
    }
    .id {
      font-size: 26px;
      z-index: 99;
    }
    .bg-img {
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      z-index: -99;
    }
  }
}
</style>